<?php
$parent = isset($CONFIG['parent']) ? (int)$CONFIG['parent'] : '';
$menu = Eleanor::$Cache->Get('menu_footer'. Language::$main . $parent);
if($menu === false) {
	$p = $menu = $menu_c_title = $menu_cont_title = $menu_i = '';
	if($parent) {
		$R = Eleanor::$Db->Query('SELECT `parents` FROM `'. P .'menu` WHERE `id` = '. $parent .' LIMIT 1');
		if(!list($p) = $R->fetch_row())
			return'';
		$p .= $parent. ',';
	}
	$r = $R = Eleanor::$Db->Query('SELECT `id`, `title` FROM `'. P .'menu` INNER JOIN `'. P .'menu_l` USING(`id`) WHERE `language` IN(\'\',\''. Language::$main .'\') AND `status`=1 AND `parents` = "'. $p .'" ORDER BY `parents` ASC, `pos` ASC');
	$i = 0;
	$so = $r->num_rows;
	while($col_t = $r->fetch_assoc()) {
		$menu_c_title .= '<td class="footer_table_title"><span>'. $col_t['title'] .'</span></td>';

		$col = $R = Eleanor::$Db->Query('SELECT `id`, `title`, `url`, `eval_url`, `params` FROM `'. P .'menu` INNER JOIN `'. P .'menu_l` USING(`id`) WHERE `language` IN(\'\', "'. Language::$main .'") AND `status` = 1 AND `parents` = "'. $p. $col_t['id'] .'," ORDER BY `parents` ASC, `pos` ASC');
		$i++;
		$menu_i = '<td><ul>';
		while($a = $col->fetch_assoc()) {
			if($a['eval_url']) {
				ob_start();
				$f = create_function('$Eleanor', $a['eval_url']);
				if($f === false) {
					ob_end_clean();
					continue;
				}
				ob_end_clean();
				$url = $f($GLOBALS['Eleanor']);
			} else {
				$url = $a['url'];
			}
			$menu_i .= '<li>'. ($url ? '<a href="'. $url .'" title="'. $a['title'] .'">'. $a['title'] .'</a>' : $a['title']) .'</li>'.( $i !== $so ? '<li class="footer_table_border"></li>' : null );
		}
		$menu_cont_title .= $menu_i ? $menu_i .'</ul></td>' : null;
	}
	$menu = '<tr>'. $menu_c_title .'</tr><tr>'. $menu_cont_title .'</tr>';
	Eleanor::$Cache->Put('menu_footer'. Language::$main . $parent, $menu);
}
return $menu;
